<?php
include('header.php');
$orgID = $_GET['id'];
$query = mysql_query("SELECT * FROM organizations WHERE orgID = '$orgID'") or die(mysql_error());
$row = mysql_fetch_assoc($query);
$orgName = $row['orgName'];
/* 
 DELETE.PHP
 Deletes a specific entry from the 'players' table
*/
?>
<div id="form_container">

<form id="form" class="appnitro" method="post" action="">
<?php // check if the 'id' variable is set in URL, and check that it is valid
if(isset($_POST['submit']) && isset($_GET['id']) && is_numeric($_GET['id'])){
	if( isset($_POST['delete'])){
		if($_POST['delete'] == 'yes'){
			// delete the entry
			$result = mysql_query("DELETE FROM organizations WHERE orgID='$orgID'")
			or die(mysql_error()); 
			// redirect back to the list page
			header('refresh:5; url=org_list.php');
       		echo '<div style="padding:4px; border:1px solid green; color:green;">Action Performed Successfully - You will be re-direct to the organizations list in 5 seconds...</div>';
		}
		else {
		header('refresh:5; url=org_list.php');
        echo '<div style="padding:4px; border:1px solid green; color:green;">Action Cancelled - You will be re-directed to the organizations list in 5 seconds...</div>';
		}
	}
	else {
	echo '<div style="padding:4px; border:1px solid red; color:red;">Error: Please Select an Option</div>';
	}
}?>
<div class="form_description">
    	<h2>Delete <?php echo $orgName ?></h2>
</div>
	<ul>
        <li>
        <span>Are you sure you want to delete this organization from the system?</span>
        <span>
        	<input name="delete" type ="radio" value ="yes" />Yes
        	<input name="delete" type ="radio" value ="no" />No
        </span>
        </li>
        <li class="button">
        	<input type="submit" name="submit" value="Submit" />
        </li>
    </ul>
</form>
</div>
<?php
include('footer.php'); 
?>